@echo off
setlocal enabledelayedexpansion

set target_path=%~1
set url_prefix=https://systemlight.tpddns.cn:8003/

call :var_len Z:\resources\ target_path_prefix_length
call :var_len "%target_path%" target_path_length

set /a use_path_length=%target_path_length%-%target_path_prefix_length%
set use_path=!target_path:~%target_path_prefix_length%,%use_path_length%!
for /f "delims=" %%i in ('python -c "from urllib import parse;print(parse.quote(r'%use_path%', safe='\\'))"') do (set encode_use_path=%%i)
call :get_file_name "%use_path%" file_name

set result=%url_prefix%%encode_use_path%
set result=%result:\=/%

set /p="- [%file_name%](%result%)"<nul | clip

setlocal disabledelayedexpansion 
exit /b


:var_len
set str_content=%~1
set length=0
:loop
if not "!str_content:~%length%,1!"=="" (
    set /a length+=1
    goto loop
)
set "%~2=%length%"
exit /b


:get_file_name
set "%~2=%~nx1"
exit /b
